#pragma once

//#define MS_PILO_CHECK_MEMORY_LEACK

#ifdef __cplusplus
#   include "common/types.h"
#   include "common/macros.h"
#else
    typedef int BOOL;
#endif

#ifdef MS_PILO_CHECK_MEMORY_LEACK
#   ifdef __cplusplus
    extern "C"
    {
#   endif

        void* MemoryAllocZeroArray(size_t nmemb, size_t size);
        void* MemoryAlloc(size_t size);
        void  MemoryFree(void *ptr);
        void* MemoryRealloc(void *ptr, size_t size);

#   ifdef __cplusplus
    }
#   endif

#   ifdef __cplusplus
#       if defined(WIN32) || defined(WINDOWS)
#           include <new.h>
            void* operator new (size_t size);
            void operator delete (void* ptr);
            void operator delete[] (void* ptr);
            _Ret_bytecap_(_Size) void *__CRTDECL operator new[](size_t _Size) _THROW1(std::bad_alloc);
#       else
#           include <new>
            void* operator new(size_t) throw (std::bad_alloc);
            void* operator new [] (size_t) throw (std::bad_alloc);
            void operator delete(void*) throw ();
            void operator delete [] (void*) throw ();
#      endif
#   endif
                
#else

#   if defined(WIN32) || defined(WINDOWS)
#       include <new.h>
#       include <malloc.h>
#   else
#       include <new>
#   endif

#   define MemoryAllocZeroArray calloc
#   define MemoryAlloc malloc
#   define MemoryFree free
#   define MemoryRealloc realloc


#endif

